package com.eqxiu.ieditor.msg.event;

import java.math.BigDecimal;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.eqxiu.wealth.api.XdLogServiceApi;

@Component
public class XdLogEventListenner {

	@Autowired
	private XdLogServiceApi xdLogService;

	@Value("${payment.appid}")
	private Long paymentAppId;

	@EventListener
	@Async
	@Transactional(readOnly = false)
	public void handleEvent(XdLogEvent event) {

		xdLogService.addXdLog(
				event.getEventId(), paymentAppId, event.getLogType(), event.getBizType(), event.getUserId(),
				new BigDecimal(event.getXdAmt()), event.getSceneId(), event.getOptTime(), event.getOptUserId(),
				event.getRemark()
		);
	}
}
